package org.siteanalyser.domain;

import java.util.ArrayList;
import java.util.List;

/**
 * Framework object for containing the results of service calls.
 * 
 * @author Luc Russell
 */
public class Message {
    private final List<String> errorMessages = new ArrayList<String>();
    private final AnalysisRequest request;
    private AnalysisReport report;

    public Message(final AnalysisRequest request, final List<String> validFieldIds, final boolean validating) {
        this.request = request;
        report = new AnalysisReport(validFieldIds);
        report.setValidating(validating);
        this.report.setRequest(request);
    }

    public List<String> getErrorMessages() {
        return errorMessages;
    }

    public void addErrorMessage(final String errorMessage) {
        errorMessages.add(errorMessage);
    }

    public AnalysisRequest getRequest() {
        return request;
    }

    public AnalysisReport getReport() {
        return report;
    }

    public void setReport(final AnalysisReport report) {
        this.report = report;
    }

    public boolean hasErrors() {
        return (errorMessages.size() == 0) ? false : true;
    }

}
